<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title></title>
    <%@ include file="/WEB-INF/views/include/easyui.jsp" %>
</head>
<body>
<div>
    <form id="mainform" action="${ctx}/shop/goodsType/${action}" method="post">
        <div class="formTopInput"></div>
        <div class="formInput">
            <div class="formInputLabel">
                <b style="color:red">*</b>类型名称：
            </div>
            <div class="formInputContent">
                <input type="hidden" name="id" value="${id }"/>
                <input name="name" type="text" value="${goodsType.name }" class="easyui-validatebox"
                       data-options="required:true,validType:['length[0,255]']"/>
            </div>
        </div>
        <div class="formInput">
            <div class="formInputLabel">
                <b style="color:red">*</b>上级类型：
            </div>
            <div class="formInputContent">
                <input id="pid" name="pid" type="text" value="${goodsType.pid }" class="easyui-validatebox"
                       data-options="required:true,validType:['length[0,11]']"/>
            </div>
        </div>
        <div class="formInput">
            <div class="formInputLabel">
                默认商品：
            </div>
            <div class="formInputContent">
                <input id="defaultGoods"/>
            </div>
        </div>
        <div class="formInput">
            <div class="formInputLabel">
                用户类型：
            </div>
            <div class="formInputContent">
                <input id="userType" name="userType" type="text" value="${goodsType.pid }" class="easyui-validatebox"
                       data-options="required:true,validType:['length[0,11]']"/>
            </div>
        </div>
        <div class="formBrInput"></div>
        <div class="formInput">
            <div class="formInputLabel">
                文件上传：
            </div>
            <div class="formInputContent">
                <div id="uploadify"></div>
            </div>
        </div>
        <%--<table class="formTable">--%>
            <%--<tr>--%>
                <%--<td></td>--%>
                <%--<td>--%>

                <%--</td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
                <%--<td>上级类型：</td>--%>
                <%--<td><input id="pid" name="pid" type="text" value="${goodsType.pid }" class="easyui-validatebox"--%>
                           <%--data-options="required:true,validType:['length[0,11]']"/></td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
                <%--<td>默认商品：</td>--%>
                <%--<td><input id="defaultGoods"/></td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
                <%--<td>用户类型：</td>--%>
                <%--<td><input id="userType" name="userType" type="text" value="${goodsType.pid }" class="easyui-validatebox"--%>
                           <%--data-options="required:true,validType:['length[0,11]']"/></td>--%>
            <%--</tr>--%>
            <%--<td>文件上传：</td>--%>
            <%--&lt;%&ndash;<td><label><input type="file" name="uploadify" id="uploadify"/></label>&nbsp;&nbsp;</td>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<td><div id="fileQueue"></div></td>&ndash;%&gt;--%>
            <%--<td>--%>
                <%--<div id="uploadify"></div>--%>
            <%--</td>--%>
            <%--</tr>--%>
        <%--</table>--%>
    </form>
</div>
<div id="addDefault"></div>
<script type="text/javascript">
    $(function () {

        //上级菜单
        $('#pid').combotree({
            width: 180,
            method: 'GET',
            url: '${ctx}/shop/goodsType/json',
            idField: 'id',
            textFiled: 'name',
            parentField: 'pid',
            animate: true
        });

        //用户类型
        $('#userType').combobox({
            url: concatURL('${ctx}/system/dict/jsonForCombobox', {dictType: "userType"}),
            method: "GET",
            valueField : 'value',
            textField : 'label',
            width:180,
            panelHeight:50
        });

        $('#mainform').form({
            onSubmit: function () {
                var isValid = $(this).form('validate');
                return isValid;	// 返回false终止表单提交
            },
            success: function (data) {
                if (successTip(data, dg, d))
                    dg.treegrid('reload');
            }
        });

        //默认商品
        $('#defaultGoods').searchbox({
            searcher: function (value, name) {
                addDefault();
            },
            menu: '#box'
        });
        $('.searchbox-text').attr('disabled','disabled');

        //文件上传
        $('#uploadify').Huploadify({
            auto: true,
            fileTypeExts: '*.jpg;*.png;*.exe;*.xls;*.xlsx',
            multi: false,
            formData: {key: 123456, key2: 'vvvv'},
            fileSizeLimit: 1024,
            showUploadedPercent: true,
            showUploadedSize: true,
            removeTimeout: 9999999,
            uploader: '${ctx}/common/uploadify',
            onUploadStart: function () {
            },
            onInit: function () {
            },
            onUploadComplete: function (file, response) {
                if (!!response) {
                    if (response == '上传成功')
                        $.messager.alert('文件："' + file.name + '"，' + response);
                    else
                        alert("上传失败");
                } else {
                    alert("上传失败");
                }
            },
            onCancel: function (file) {
            }
        });

    });

    //默认商品弹窗
    function addDefault(){
        d=$('#addDefault').dialog({
            title: '添加菜单',
            width: 980,
            height: 610,
            closed: false,
            cache: false,
            maximizable:true,
            resizable:true,
            href:'${ctx}/shop/goodsListPopup',
            modal: true,
            buttons:[{
                text:'确认',
                handler:goodsListPopCallback
            },{
                text:'取消',
                handler:function(){
                    d.panel('close');
                }
            }],
            onClose : function(){
               if(!isBlank(callbackObj))
                   console.log(callbackObj);
            }
        });
        dialogId = d;
    }

    function goodsListPopCallback(){
        debugger;
        var row = dialogDg.datagrid('getSelected');
        if(rowIsNull(row)) return;
        convert2ObjBean(row) ;//单个对象 字段 数据库类型 转bean   数组对象 转 convert2BeanList(data
        dialogId.dialog('close');
    }
</script>
</body>
</html>